package com.deluxelx.soul.inn.common.constant;

import cn.hutool.core.util.StrUtil;
import com.deluxelx.soul.inn.common.param.CollectedParam;

import static com.deluxelx.soul.inn.common.constant.UserConstant.USER_CACHE_KEY_PREFIX;

/**
 * 心里问答-常数类
 *
 * @author liaozihao
 * @date 2024-04-25 15:22
 */
public class QuestionConstant {

    public static final String TAG_CACHE_KEY = "TagCache";

    public static final String QUESTION_READ_KEY = "readQuestion";

    public static final String QUESTION_CACHE_KEY_PREFIX = "question_";

    public static final String QUESTION_FOLLOW_KEY = "followQuestion";

    public static final Integer QUESTION_CACHE_EXPIRE_TIME = 60 * 60 * 24 * 7;

    public static final String questionTaskPattern1 = "user_*:question_*";

    public static final String questionTaskPattern2 = "followQuestion:*";

    public static final String questionTaskPattern3 = "readQuestion:*";

    public static String buildFollowQuestionKey(CollectedParam param) {
        return USER_CACHE_KEY_PREFIX + param.getUserId() + StrUtil.COLON + QUESTION_CACHE_KEY_PREFIX + param.getQuestionId();
    }

    public static String buildFollowQuestionKey(String questionId) {
        return QUESTION_FOLLOW_KEY + StrUtil.COLON + questionId;
    }

    public static String buildReadQuestionKey(String questionId) {
        return QUESTION_READ_KEY + StrUtil.COLON + questionId;
    }

}
